import React, { Component } from "react";
//引入react-redux包
import { connect } from "react-redux";
class Address extends Component {
    render() {
        console.log(this.props.list);

        return (
            <div className="address">
                <div className="addr_list">
                    {this.props.list.map((item, index) => {
                        return (
                            <div
                                className="item"
                                key={item.id}
                                onClick={() => {
                                    this.props.history.push({
                                        pathname: "/cart",
                                        state: item
                                    });
                                }}
                            >
                                <h3>{item.addr}</h3>
                                <p>
                                    <span>{item.name}</span>
                                    <span>{item.phone}</span>
                                </p>
                            </div>
                        );
                    })}
                </div>
                <div
                    className="add-address"
                    onClick={() => {
                        this.props.history.push("/add_address");
                    }}
                >
                    新增收货地址
                </div>
            </div>
        );
    }
}
export default connect(
    state => {
        return {
            list: state.addressList
        };
    },
    dispatch => {
        return {};
    }
)(Address);
